package com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.view;

import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.MyOrganizationAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseActivity;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.custom_view.NoScrollViewPager;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.MyOrganizationFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.MyOrganizationMembersFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.contract.IMyOrganizationContract;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.persenter.MyOrganizationPersenter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/13.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class MyOrganizationActivity extends BaseActivity implements IMyOrganizationContract.IMyOrganizationView {
    private MyOrganizationPersenter mMyOrganizationPersenter = new MyOrganizationPersenter(this);
    private EditText et_sreach;
    private TextView tv_name;
    private TextView tv_organization_name;
    private NoScrollViewPager no_scroll_viewpager;
    private MyOrganizationAdapter myOrganizationAdapter;  //onSwitchOrganization
    private int index = 0;

    @Override
    protected void userAgreedPermissions() {

    }

    @Override
    protected View AddLayoutView() {
        View view = View.inflate(this, R.layout.activity_my_organization,null);
        et_sreach = view.findViewById(R.id.activity_my_organization_et_sreach);
        tv_name = view.findViewById(R.id.activity_my_organization_tv_name);
        tv_organization_name = view.findViewById(R.id.activity_my_organization_tv_organization_name);
        no_scroll_viewpager = view.findViewById(R.id.activity_my_organization_my_no_scroll_viewpager);
        return view;
    }

    @Override
    protected void initChildViewDate() {
        mMyOrganizationPersenter.initTitle();
        List<Fragment> list = new ArrayList<>();
        list.add(new MyOrganizationFragment());
        list.add(new MyOrganizationMembersFragment());
        no_scroll_viewpager.setScroll(false);
        myOrganizationAdapter = new MyOrganizationAdapter(getSupportFragmentManager(),this,list);
        no_scroll_viewpager.setAdapter(myOrganizationAdapter);
    }

    @Override
    protected void onClickedTvRight() {

    }

    @Override
    public void onClickedIvRight() {
        if(index == 0){
            index = 0;
            finish();
        }else{
            index--;
            if(no_scroll_viewpager != null){
                no_scroll_viewpager.setCurrentItem(0);
            }
        }

    }

    @Override
    protected void onClickedIvLeft() {

    }

    @Override
    public void showTitle() {
        showTilteBg();
        showTitleContent();
        showTileIvLeft();
        showTileIvRight();
        //设备管理(6)
        setTitleContent("我的组织", 0xffffffff);
        setIvLeftIcon(R.mipmap.left_white_return);
        setIvLeftRight(R.mipmap.share_and_download);
    }

    @Override
    public String getInputSearch() {
        return et_sreach.getText().toString().trim();
    }

    @Override
    public void setName(String name) {
        tv_name.setText(name);
    }

    @Override
    public void setOrganizatioName(String name) {
        tv_organization_name.setText(name);
    }
    /**
     *切换fragment
     * */
    public void SwitchFragments(){
        no_scroll_viewpager.setCurrentItem(1);
    }
    /**
     * @desc 添加索引
     * */
    public void addIndex(){
        index ++;
    }


}
